<extend name="Public:base" />
<block name="main">
	<div class="content">
		<section class="location">
			<i class="iconfont">&#xe60f</i> 位置：<a href="{:U('Index/main')}">管理首页</a> &gt; <a href="{:U('index')}">文章管理</a> &gt; 编辑文章
		</section>
		<ul class="nav-tabs clearfix">
			<li><a href="{:U('password')}">修改密码</a></li>
			<li><a href="{:U('index')}">管理员列表</a></li>
			<li><a href="{:U('add')}">新增管理员</a></li>
			<li class="active">编辑管理员</li>
		</ul>
		<form method="post" action="" id="form">
			<input type="hidden" name="id" id="id" value="{$viewInfo.id}" />
			<table width="100%" border="0" cellspacing="0" cellpadding="0" class="table">
				<tr>
					<th width="100">登陆ID</th>
					<td><input type="text" name="username" id="username" value="{$viewInfo.username}" class="form-control form-control-sm" disabled /> <span class="red"> *</span> </td>
				</tr>
				<tr>
					<th>密码</th>
					<td><input type="password" name="password" id="password" class="form-control form-control-sm" required /> <span class="red"> *</span>不修改密码请留空</td>
				</tr>
				<tr>
					<th>笔名</th>
					<td><input type="text" name="author" id="author" value="{$viewInfo.author}" class="form-control form-control-sm" /></td>
				</tr>
				<tr>
					<th>用户类型</th>
					<td>
						<select name="usertype" id="usertype" class="form-control">
							<option value="2" <eq name="viewInfo.usertype" value="2">selected</eq>>信息发布员</option>
							<option value="1" <eq name="viewInfo.usertype" value="1">selected</eq>>超级管理员</option>
						</select>
					</td>
				</tr>
				<tr>
					<th>负责栏目</th>
					<td>
						<select name="typeids[]" id="typeids" size="10" multiple="true">
							<option value="0" <eq name="viewInfo.typeids" value="0">selected</eq>>——所有栏目——</option>
							<foreach name="category" item="list">
							<option value="{$list.id}" <in name="list.id" value="$viewInfo.typeids">selected</in>>{$list.delimiter}<if condition="$list.parent_id neq 0">├─</if>{$list.name}</option>
							</foreach>
						</select>
					</td>
				</tr>
				<tr>
					<th>真实姓名</th>
					<td><input type="text" name="name" id="name" value="{$viewInfo.name}" class="form-control form-control-sm" /></td>
				</tr>
				<tr>
					<th>联系电话</th>
					<td><input type="text" name="phone" id="phone" value="{$viewInfo.phone}" class="form-control form-control-sm" /></td>
				</tr>
				<tr>
					<th>电子邮箱</th>
					<td><input type="text" name="email" id="email" value="{$viewInfo.email}" class="form-control form-control-sm" /></td>
				</tr>
			</table>
			<div class="well"><button type="submit" class="btn btn-theme" id="submit_admin">保 存</button> <button class="btn btn-gary" onclick="javascript:history.back(-1);">返 回</button></div>
		</form>
	</div>
</block>
<block name="JS">
<script>
	$('#submit_admin').click(function(){
		event.preventDefault();
		var Url = "{:U('edit')}";
		$.ajax({
			type: 'post',
			url: Url,
			data: $("#form").serialize(),
			success: function(data){
				if(data.status==1){
					swal({
						title: data.msg,
						text: "",
						type: 'success',
						showCancelButton: false,
						confirmButtonText: '确定'
					}).then(function() {
						location.href = data.callback;
					});
				}else{
					swal(data.msg,'','error');
				}
			}
		});
	});
</script>
</block>